//
//  BaoZhengTableViewCell.m
//  ShangChengMoBan
//
//  Created by yaoqi yaoqi on 16/9/6.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "BaoZhengTableViewCell.h"

@implementation BaoZhengTableViewCell
{
    UILabel * _labTit;
    UIImageView * _view;
    UILabel * _content;
}
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.frame = CGRectMake(0, 0, KScreenWidth, _H);

        [self initCell];
    }
    return self;
}
-(void)initCell{
    _view = [[UIImageView alloc]init];
    _view.image = [UIImage imageNamed:@"对勾"];
    [self addSubview:_view];
    _labTit = [[UILabel alloc]init];
    _labTit.font = [UIFont systemFontOfSize:13];
    _labTit.textColor = MaintextColor;
    [self addSubview:_labTit];
    _content = [[UILabel alloc]init];
    _content.font = [UIFont systemFontOfSize:11];
    _content.textColor = [UIColor grayColor];
    _content.numberOfLines = 0;//多行
    [self addSubview:_content];
}
-(void)setDic:(NSDictionary *)dic{
    _view.frame = CGRectMake(10, 10, 15, 15);
    _labTit.frame = CGRectMake(_view.right+15, 10, KScreenWidth-50, 15);
    _labTit.text = dic[@"title"];
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:dic[@"content"]];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    [paragraphStyle setLineSpacing:3];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, ((NSString *)dic[@"content"]).length)];
    //获取计算高度
    CGSize contentSize = [dic[@"content"] boundingRectWithSize:CGSizeMake(KScreenWidth-_view.right-25, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11],NSParagraphStyleAttributeName:paragraphStyle} context:nil].size;
    _content.frame = CGRectMake(_view.right+15, _labTit.bottom+5, contentSize.width, contentSize.height);
    _content.attributedText = attributedString;
    if ([dic[@"content"]isEqualToString:@""]) {
        _content.frame = CGRectMake(_view.right+15, _labTit.bottom+5, contentSize.width,0);
    }

    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, _content.bottom+10, KScreenWidth, 1)];
    view.backgroundColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.87 alpha:1.00];
    [self addSubview:view];
    _H = view.bottom;
}
@end
